var form = null;
var valid = null;
function initForm(ff) {
    try {
        form = ff;
        /*初始化表单验证*/
        valid = form.myValid();
    } catch (e) {
        console.error("初始化表单失败");
    }

}

function initSubmit() {
    try {
        var btnSubmit = form.find(".controls > button:eq(0)");
        btnSubmit.bind("click", function () {
            iSubmit(form, $(this), valid, null, null, null);
        });
    } catch (e) {
        console.error("初始化提交按钮失败");
    }
}

function initReset() {
    try {
        var btnReset = form.find(".controls > button:eq(1)");
        btnReset.bind("click", function () {
            iReset(form, $(this), valid);
        });
    } catch (e) {
        console.error("初始化重置按钮失败");
    }
}

function deleteFunction(obj, table) {
    try {
        var selectedUsers = $("table").find(".warning");
        var ids = [];
        ids[0] = "int";
        selectedUsers.each(function (i) {
            var id = $(this).find("td").last().html();
            ids[++i] = id;
        });
        var data = obj.attr("paramName") + "=" + arrayToJson(ids);
        iAjaxPost(obj.attr("href"), data, function () {
            window.location.href = obj.attr("href2");
        }, $(this), table);
    } catch (e) {
        console.error("初始化删除函数失败");
    }
}